/*导入 Excel */
function btnImport(attachmentParamterId) {

    if (attachmentParamterId == "" || attachmentParamterId == null) {
        return $.alert("default", "info", "未获取到当前页面的附件参数id");
    }
    var url = '/common/importExcel/importExcel?attachmentParamterId=' + attachmentParamterId;
    top.layer.open({
        type: 2,
        title: 'Excel导入',
        shadeClose: false,
        shade: 0.3,
        area: ['500px', '250px'],
        content: url,
        maxmin: false
    });
}

/* 导出EXCEL (示例代码、导出用户)  */
function btnExport(attachmentParamterId) {

    if (attachmentParamterId == "" || attachmentParamterId == null) {
        return $.alert("default", "info", "未获取到当前页面的附件参数id");
    }
    var url = String.format("/common/importExcel/excelExportData?attachmentParamterId={0}", attachmentParamterId);
     $("#iframe").attr('src', url);

}

/**
 * @Method
 * @Param attachmentParamterId：附件参数id，readonly：是否只读
 * @Return
 * @Exception
 * @Description [附件上传下载]
 * @Author      dsd
 * @Version     1.0
 * @Date        2017/12/28 16:22
 */
function attachmentManager(attachmentParamterId, readonly) {

    if (attachmentParamterId == "" || attachmentParamterId == null) {
        return $.alert("default", "info", "未获取到当前页面的附件参数id");
    }
    var url;
    if (readonly) {
        //只读模式
        url = '/common/attachment/attachmentReadonly?attachmentParamterId=' + attachmentParamterId;
        attachment(url);
    } else {
        url = '/common/attachment/attachment?attachmentParamterId=' + attachmentParamterId;
        attachment(url);
    }
}

//附件上传下载
function attachment(url) {
    top.layer.open({
        type: 2,
        title: '附件',
        shadeClose: false,
        shade: 0.3,
        area: ['900px', '600px'],
        content: url,
        maxmin: true,
        end: function () {
            btnQuery();
        }
    });
}


/**
 * @Method
 * @Param attachmentParamterId：附件参数id，readonly：是否只读
 * @Return
 * @Exception
 * @Description [附件上传下载]
 * @Author      dsd
 * @Version     1.0
 * @Date        2017/12/28 16:22
 */
function attachmentSingleManager(attachmentParamterId, readonly) {

    if (attachmentParamterId == "" || attachmentParamterId == null) {
        return $.alert("default", "info", "未获取到当前页面的附件参数id");
    }
    var url;
    if (readonly) {
        //只读模式
        url = '/common/attachment/attachmentSingleReadonly?attachmentParamterId=' + attachmentParamterId;
        attachmentSingle(url);
    } else {
        url = '/common/attachment/attachmentSingle?attachmentParamterId=' + attachmentParamterId;
        attachmentSingle(url);
    }
}

/*单附件 */
function attachmentSingle(url) {

    top.layer.open({
        type: 2,
        title: '',
        shadeClose: true,
        shade: 0,
        area: ['500px', '170px'],
        content: url,
        maxmin: false,
        closeBtn: 0
    });
}
